package com.example.j2eeapp.commons.dao;

import java.io.Serializable;
import java.util.List;

/**
 * 
 * Generic Interface for Data Access Objects, To be extended or implemented
 * Contains common persistence methods.
 * 
 * @author cipherCata
 *  
 */

//It means that the class can be serialized. This means that it can be converted into an stream of 0's and 1's 
//and be sent to other service, like a webservice or and ORM (hibernate) or whatever. Then this service knows how store the stream.
//Also, your program can receive a serialized class and create an instance for it from the stream of 0's and 1's.
//It's the way to "save" instances of classes and "restore" them at any other moment in time.

//Allow it to except any entity types base on its ID that can/will be serialized
public interface GenericDao<T, ID extends Serializable> {
    
	//methods commonly use; save the <T> type to be know in the future
    T save(T entity);
    T update(T entity);
    void delete(T entity);
    T findById(ID id);
    List<T> findAll();
    void flush();
}